<%@ page contentType="text/html;charset=UTF-8" import="java.sql.*" %>
<%
    String id = request.getParameter("id");
    String name = "";
    String gender = "";
    String phone = "";

    if (id != null) {
        String JDBC_DRIVER = "com.mysql.jdbc.Driver";
        String DB_URL = "jdbc:mysql://localhost:3306/sims";
        String USER = "root";
        String PASS = "123456";
        
        Class.forName(JDBC_DRIVER);
        Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
        
        String sql = "SELECT * FROM student WHERE id=?";
        PreparedStatement psmt = conn.prepareStatement(sql);
        psmt.setInt(1, Integer.parseInt(id));
        ResultSet rs = psmt.executeQuery();

        if (rs.next()) {
            name = rs.getString("name");
            gender = rs.getString("gender");
            phone = rs.getString("phone");
        }
    }
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Edit Student</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f2f2f2;
            text-align: center;
        }

        form {
            margin: 20px auto;
            width: 50%;
            padding: 20px;
            background-color: #fff;
            box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
        }

        label {
            display: inline-block;
            width: 100px;
            text-align: right;
            margin-bottom: 10px;
        }

        input[type="text"] {
            padding: 8px;
            border-radius: 4px;
            border: 1px solid #ccc;
            margin-bottom: 10px;
        }

        input[type="submit"] {
            padding: 8px 12px;
            border: none;
            background-color: #007bff;
            color: #fff;
            cursor: pointer;
        }

        input[type="submit"]:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
    <form action="edit_do.jsp" method="post">
        <input type="text" name="id" value="<%= id %>">
        <label for="name">姓名:</label>
        <input type="text" name="name" value="<%= name %>"><br>
        <label for="gender">性别:</label>
        <input type="text" name="gender" value="<%= gender %>"><br>
        <label for="phone">手机号码:</label>
        <input type="text" name="phone" value="<%= phone %>"><br>
        <input type="submit" value="修改">
    </form>
</body>
</html>